VER = 1.3.2
APP = sqlim-$(VER)

TPL =                  \
src/tpl/sqlim.css      \
src/tpl/footer.tpl     \
src/tpl/header.tpl     \
src/tpl/period.tpl     \
src/tpl/ulist.tpl      \
src/tpl/user.tpl       \
src/tpl/users.tpl      \
src/tpl/detail.tpl

CGI =                  \
src/cgi-bin/detail.cgi \
src/cgi-bin/index.cgi 

OTHER =                \
src/db.sql             \
src/history.txt        \
src/readme.txt

CMD =                  \
src/pass_basic         \
src/pass_basic_del     \
src/sq2db.pl           \
src/sqlim_acl.pl       \
src/sqlim_sum.pl       \
src/util.pl            \
src/config.pl   

SRC = $(TPL) $(CGI) $(CMD) $(OTHER)

all: $(APP).rpm $(APP).tar.gz

$(APP).tar.gz: $(SRC)
	@chmod +x $(CGI) $(CMD)
	@mkdir $(APP)
	@cp $(OTHER) $(CMD) $(APP)/
	@mkdir $(APP)/tpl
	@cp $(TPL) $(APP)/tpl/
	@mkdir $(APP)/cgi-bin
	@cp $(CGI) $(APP)/cgi-bin/
	@tar -czf $(APP).tar.gz $(APP)/
	@rm -drf ./$(APP)

$(APP).rpm: $(SRC) sqlim.spec
	@rpmbuild --quiet -ba sqlim.spec

clean:
	-@rm $(APP).tar.gz
	-@rm $(APP).rpm
